package com.yanqu.road.entity.autodata.chefduel2;

import com.yanqu.road.entity.DataStatus;
import com.yanqu.road.entity.FieldTypeAnnotation;
import com.yanqu.road.entity.autodata.AutoDataObject;

import java.util.concurrent.ConcurrentHashMap;

/**
 * @Author : Cxp
 * @Time : 2024-11-29
 * @Description : 小当家二阶段自动回访汤勺
 */

@FieldTypeAnnotation(tableName = "t_u_activity_chefduel2_auto_join_spoon")
public class ChefDuel2AutoJoinSpoon extends AutoDataObject {
    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "玩家ID", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "汤勺数量")
    private ConcurrentHashMap<Integer, Integer> spoonMap;

    @FieldTypeAnnotation(desc = "是否返回 0-否 1-是")
    private int isReturn;

    public ChefDuel2AutoJoinSpoon() {}

    public ChefDuel2AutoJoinSpoon(int activityId, long userId, int isReturn) {
        this.activityId = activityId;
        this.userId = userId;
        this.isReturn = isReturn;
        setInsertOption();
    }

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setOp(DataStatus.Update);
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setOp(DataStatus.Update);
        }
    }

    public ConcurrentHashMap<Integer, Integer> getSpoonMap() {
        return spoonMap;
    }

    public void setSpoonMap(ConcurrentHashMap<Integer, Integer> spoonMap) {
        if (this.spoonMap != spoonMap) {
            this.spoonMap = spoonMap;
            setOp(DataStatus.Update);
        }
    }

    public int getIsReturn() {
        return isReturn;
    }

    public void setIsReturn(int isReturn) {
        if (this.isReturn != isReturn) {
            this.isReturn = isReturn;
            setOp(DataStatus.Update);
        }
    }

    public void modifySpoonCnt(int spoonId, int cnt) {
        if (!this.spoonMap.containsKey(spoonId) || cnt == 0) {
            return;
        }
        this.spoonMap.merge(spoonId, cnt, Integer::sum);
        setOp(DataStatus.Update);
    }
}
